﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

using CtpTrader.Core.Common;
using CtpTrader.Core.Quote;

namespace CtpTrader.Client
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        private void Form1_Load(object sender, EventArgs e)
        {
            foreach (string instrument in InstrumentManager.GetSubscribe())
            {
                BarSeries bar = new BarSeries(instrument, new BarUnit() { Level = 1, TimeSpan = BarTimeSpan.Minutes });

                bar.PriceUpdate += new BarSeries.PriceUpdateDelegate(bar_PriceUpdate);

                QuoteManager.GetInstance().Add(bar);
            }

            QuoteManager.GetInstance().Start();
        }

        void bar_PriceUpdate(BarSeries series)
        {
            if (this.textBox1.BackColor == Color.Blue)
                this.textBox1.BackColor = Color.White;
            else
                this.textBox1.BackColor = Color.Blue;

            this.textBox1.Text = series[0].Close.ToString();
        }
    }
}
